package com.ai.entity.network;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;

/**
 * DS收到L1发送的电文内容
 * @Author jiaok
 * @Date 2023-06-20 10:48
 */
@Data
public class L1ToDsSysMessage implements Serializable {
    @ApiModelProperty(value = "电文长度，固定值256")
    private String length;

    @ApiModelProperty(value = "电文号，固定值SIDS01")
    private String teleNo;
    @ApiModelProperty(value = "上表面准许作业，建张完成并允许作业")
    private String allowHomeworkTop;

    @ApiModelProperty(value = "下表面准许作业，建张完成并允许作业")
    private String allowHomeworkDown;

    @ApiModelProperty(value = "作业模式（自动/手动），使用是自动还是手动模式")
    private String operationMode;

    @ApiModelProperty(value = "上表面建张张力，单位MM，格式为6,3")
    private BigDecimal tensionTop;

    @ApiModelProperty(value = "下表面建张张力，单位MM，格式为6,3")
    private BigDecimal tensionDown;
    @ApiModelProperty("预留字段")
    private String spare;

    @ApiModelProperty("信号来源")
    private String clientIp;

    @ApiModelProperty("端口")
    private Integer sourcePort;
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;


    @Override
    public boolean equals(Object o) {
        if (o == null){
            return false;
        }
        L1ToDsSysMessage that = (L1ToDsSysMessage) o;
        that.setTensionTop(that.getTensionTop().setScale(3, RoundingMode.HALF_UP));
        that.setTensionDown(that.getTensionDown().setScale(3, RoundingMode.HALF_UP));
        return allowHomeworkTop.equals(that.allowHomeworkTop) && allowHomeworkDown.equals(that.allowHomeworkDown) && operationMode.equals(that.operationMode) && tensionTop.equals(that.tensionTop) && tensionDown.equals(that.tensionDown);
    }

}
